import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/modules/recharge/views/recharge_item_header.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'package:honeypotflutter/public/views/public_scrollView.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/bussine_image.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_button.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_card.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_item.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_switchMonry.dart';
import 'logic.dart';

class RechargePayPage extends StatefulWidget {
  const RechargePayPage({Key? key}) : super(key: key);

  @override
  State<RechargePayPage> createState() => _RechargePayPageState();
}

class _RechargePayPageState extends State<RechargePayPage> {
  final RechargePayLogic logic = Get.put(RechargePayLogic());
  final double payMonry = Get.arguments;
  final TapGestureRecognizer _gestureRecognizer = TapGestureRecognizer();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HLAppBar(navigationTitle: "充值"),
      body: HLScrollView(
        padding: EdgeInsets.all(16),
        children: [
          MGCard(
            backColor: MGColors.themeColor.withOpacity(0.7),
            padding: EdgeInsets.only(top: 35, bottom: 35),
            children: [
              MGSwitchMonry(
                title: "充值金额(元)",
                showExchange: false,
                color: MGColors.text1Color,
                crossAxisAlignment: CrossAxisAlignment.center,
                monry: payMonry,
              )
            ],
          ),
          MGCard(
            margin: EdgeInsets.only(top: 25),
            children: [
              RechargeItemHeader(),
              MGItems(
                leadIcon: MGImage.image("recharge_wechat", type: ImagePathType.recharge),
                leadTitle: "微信支付",
                trailingWidget: Obx(() => Image.asset(
                      MGImage.image(logic.selectIndex.value == 0 ? "public_pass" : "public_no_pass"),
                      width: 22,
                    )),
                action: () {
                  logic.selectIndex.value = 0;
                },
              ),
              MGItems(
                leadIcon: MGImage.image("recharge_alpay", type: ImagePathType.recharge),
                leadTitle: "支付宝支付",
                trailingWidget: Obx(() => Image.asset(
                      MGImage.image(logic.selectIndex.value == 1 ? "public_pass" : "public_no_pass"),
                      width: 22,
                    )),
                action: () {
                  logic.selectIndex.value = 1;
                },
              ),
            ],
          )
        ],
      ),
      bottomNavigationBar: Container(
        color: MGColors.whileColor,
        padding: EdgeInsets.only(bottom: 30, left: 20, right: 20, top: 20),
        child: Column(
          children: [
            Text.rich(TextSpan(children: [
              TextSpan(
                text: "充值即代表阅读并同意",
                style: TextStyle(
                  color: MGColors.text3Color,
                  fontSize: MGFont.textFont3,
                ),
              ),
              TextSpan(
                text: "《充值协议》",
                style: TextStyle(
                  color: MGColors.blueColor,
                  fontSize: MGFont.textFont3,
                ),
                recognizer: logic.gestureRecognizer,
              ),
            ])),
            MGButton(
              title: "下一步",
              margin: EdgeInsets.only(top: 20),
              buttonAction: logic.nextClick,
            )
          ],
          mainAxisSize: MainAxisSize.min,
        ),
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<RechargePayLogic>();
    super.dispose();
  }
}
